package cn.clq.ymcc.web.controller;

import cn.clq.ymcc.domain.Login;
import cn.clq.ymcc.dto.RegisterDto;
import cn.clq.ymcc.result.JSONResult;
import cn.clq.ymcc.service.IMessageVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * @author clqlongbao
 * @version 1.0
 * @description: TODO
 * @date 2022/7/15 19:20
 */
@RestController
@RequestMapping("/verifyCode")
public class MessageVerifyCodeController {
    @Autowired
    private IMessageVerifyCodeService messageVerifyCodeService;

    /**
     * @description: 发送图形验证码
     * @param: imageCodeKey
     * @return: cn.clq.ymcc.result.JSONResult
     * @author clqlongbao
     * @date: 2022/7/15 18:48
     */
    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult imageCode(@PathVariable("imageCodeKey") @NotEmpty(message = "UUID怎么会为空呢？") String imageCodeKey){
        String base64Str = messageVerifyCodeService.imageCode(imageCodeKey);
        return JSONResult.success(base64Str);
    }
    /**
     * @description: 发送短信验证码
     * @param: imageCodeKey
     * @return: cn.clq.ymcc.result.JSONResult
     * @author clqlongbao
     * @date: 2022/7/15 19:53
     */
    @PostMapping("/sendSmsCode")
    public JSONResult smsCode(@RequestBody @Valid RegisterDto dto){
        messageVerifyCodeService.sendSmsCode(dto);
        return JSONResult.success();
    }

}
